﻿using HandyControl.Controls;
using Super.Hmi.Global;
using Super.Hmi.Utils.ThemeManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Window = System.Windows.Window;

namespace Super.Hmi.Views
{
    /// <summary>
    /// MainView.xaml 的交互逻辑
    /// </summary>
    public partial class MainView : Window
    {
        public MainView()
        {
            InitializeComponent();

            new ThemeConfig().AppearanceSettings.Theme.ThemeType = ThemeType.Dark;
        }

        private void BtnClose_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();
        }

        private void BtnRestore_Click(object sender, RoutedEventArgs e)
        {
            if (WindowState == WindowState.Normal)
            {
                this.WindowState = WindowState.Maximized;
                // 设置图标
                if (Application.Current.Resources["WindowRestoreGeometry"] is Geometry geometry)
                {
                    BtnRestore.SetValue(IconElement.GeometryProperty, geometry);
                }
                WindowFunctionAre.Margin = new Thickness(0, -5, 0, 0);
            }
            else if (WindowState == WindowState.Maximized)
            {
                this.WindowState = WindowState.Normal;
                // 设置图标
                if (Application.Current.Resources["WindowMaxGeometry"] is Geometry geometry)
                {
                    BtnRestore.SetValue(IconElement.GeometryProperty, geometry);
                }
                WindowFunctionAre.Margin = new Thickness(0, -10, 0, 0);
            }
        }

        private void BtnWindowMin_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }
    }
}
